package com.koylu.faces.security;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.koylu.faces.security.user.Group;

public class AccessGroup implements Group{
	
	private String name;
	private List   rights;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public List getRights() {
		return rights;
	}
	public void setRights(List rights) {
		this.rights = rights;
	}
	
	public void addRight(AccessRight right){
		if(rights == null){
			rights = new ArrayList();
		}
		rights.add(right);
	}
	
	public boolean check(Group group) {
		if(name != null && group != null){
			return name.equalsIgnoreCase(group.getName());
		}
		return false;
	}
	
	public String toString() {		
		return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
	}		

}
